package com.bw.baserecyclerview.diff;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.bw.baserecyclerview.R;

import java    .util.List;

public class DiffAcapter extends RecyclerView.Adapter<DiffAcapter.DiffVH>{

    private List<DiffEntity> list;

    public DiffAcapter(List<DiffEntity> list){
        this.list = list;
    }

    public List<DiffEntity> getList() {
        return list;
    }

    @NonNull
    @Override
    public DiffVH onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_diff,parent,false);
        return new DiffVH(itemView);
    }

    @Override
    public void onBindViewHolder(@NonNull DiffVH holder, int position) {
        holder.itemTv.setText(list.get(position).title);
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    public static class DiffVH extends RecyclerView.ViewHolder{

        TextView itemTv;

        public DiffVH(@NonNull View itemView) {
            super(itemView);
            itemTv = itemView.findViewById(R.id.item_diff_tv);
        }
    }

}
